package com.estun.backroundManagementService.modules.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.estun.backroundManagementService.modules.product.mapper.ProductValueMapper;
import com.estun.backroundManagementService.modules.product.model.Product;
import com.estun.backroundManagementService.modules.product.model.ProductValue;
import com.estun.backroundManagementService.modules.product.service.ProductValueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 产品参数表 服务实现类
 * </p>
 *
 * @author machine
 * @since 2023-02-14
 */
@Service
public class ProductValueServiceImpl extends ServiceImpl<ProductValueMapper, ProductValue> implements ProductValueService {


    @Autowired
    private ProductValueMapper productValueMapper;

    @Override
    public Product getProductByStationId(String stationId) {
        return productValueMapper.selectProductByStationId(stationId);
    }

    @Override
    public List<ProductValue> getByLatestStationId(String stationId) {
        return productValueMapper.selectLatestByStationId(stationId);
    }

    @Override
    public List<ProductValue> getByProductIdAndStationId(Long productId, String stationId) {
        return list(new QueryWrapper<ProductValue>().eq("product_id", productId).eq("station_id", stationId));
    }
}
